package com.freshcity.page.feiji
{
	import com.freshcity.component.container.Component;
	import com.freshcity.core.Dispatcher;
	import com.freshcity.core.MainScene;
	import com.freshcity.core.OpCodes;
	import com.freshcity.feiji.StarFeijiWin;
	import com.freshcity.lib.event.EventName;
	import com.freshcity.manager.LayerManager;
	import com.greensock.TweenMax;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class StarFeiji extends Component
	{
		private var _data:*;
		
		private var back:StarFeijiWin;
		public function StarFeiji(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			this.visible = false;
			super(parent, xpos, ypos);
			
			back.closeBtn2.addEventListener(MouseEvent.CLICK,hide);
			back.closeBtn.addEventListener(MouseEvent.CLICK,hide);
			back.wordBtn.addEventListener(MouseEvent.CLICK,showUser);
		}
		
		protected function showUser(event:MouseEvent):void
		{
			Dispatcher.addEventListener(EventName.UserReadDone,main.showUser);
			main.findUser(data.fromUser);
		}
		
		override protected function addChildren():void
		{
			super.addChildren();
			back = new StarFeijiWin();
			addChild(back);
		}
		
		override public function draw():void
		{
			super.draw();
		}
		
		private function resort():void
		{
			back.scoreValue.text=data.score;
			//back.yesAmt.text=data.yesAmt;
			//back.noAmt.text=data.noAmt;
			//back.ignoreAmt.text= String(data.ignoreAmt-1);
			back.expDate.htmlText = data.createdAt;
			back.designer.text = "用户"+data.fromUser;
			back.wordContent.text = data.content;
		}
		
		override public function destroy():void
		{
			super.destroy();
		}
		
		override public function hide(event:Event=null):void
		{
			TweenMax.to(this,0.3,{autoAlpha:0,scaleX:0.6,scaleY:0.6,onComplete:destroy});
		}
		
		override public function show(event:Event=null):void
		{
			if(!this.parent){
				LayerManager.sceneLayer.addChild(this);
			}
			this.x = (main.stage.stageWidth-width)/2;
			this.y = (main.stage.stageHeight-height)/2;
			this.scaleX = 0.6;
			this.scaleY = 0.6;
			TweenMax.to(this,0.3,{autoAlpha:1,scaleX:1,scaleY:1});
		}

		public function get data():*
		{
			return _data;
		}

		public function set data(value:*):void
		{
			_data = value;
			resort();
		}
	}
}